#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>

#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); } \
										while(0)

int main(int argc, char ** argv){

	if(argc != 2){
				fprintf(stderr, "Usage: %s number of megabytes of memory it will use\n",
											argv[0]);	
				exit(EXIT_FAILURE);
	}
	
	int num_mem = atoi(argv[1]);

	printf("Process_PID(:%d)\n", getpid());

	char *arr = (char *)malloc(sizeof(char) * num_mem * 1024 * 1024);

	unsigned long i = 0;

	if(arr == NULL)
				 errExit("malloc error!");

	while(1){
		arr[i] = 0;	
		i++;
		if(i == num_mem * 1024 * 1024)
				i = 0;
	}
	
	return 0;
}
